﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microhard.Permission.Interface;
using Microhard.Permission.MVCFilter;

namespace Microhard.WebUI.Areas.Admin.Controllers
{
    public class DataDicAttr
    {
        public int TypeID { set; get; }
        public string CtrName { set; get; }
        public List<SelectListItem> Items { set; get; }
        public string SelectedID { set; get; }
    }


    public class DataDictionaryController : Controller
    {
        [MVCFilterAtrForLogon]
        public ActionResult DataDicSelectList(DataDicAttr attr)
        {
            if (attr != null)
            {
                attr.Items = new List<SelectListItem>();
                attr.Items.Add(new SelectListItem { Text = "请选择", Value = string.Empty });
                attr.Items.Add(new SelectListItem { Text = "新洲", Value = "新洲" });
                attr.Items.Add(new SelectListItem { Text = "黄陂", Value = "黄陂" });
                attr.Items.Add(new SelectListItem { Text = "汉南", Value = "汉南" });
                attr.Items.Add(new SelectListItem { Text = "江夏", Value = "江夏" });
                attr.Items.Add(new SelectListItem { Text = "蔡甸", Value = "蔡甸" });
                if (!string.IsNullOrEmpty(attr.SelectedID))
                {
                    foreach (var a in attr.Items)
                    {
                        if (a.Value.ToLower() == attr.SelectedID.ToLower())
                        {
                            a.Selected = true;
                            break;
                        }
                    }
                }
            }
            return View("DataDicSelectList", attr);
        }

    }
}
